package com.efounder.form.service;

import android.util.Log;

import com.efounder.builder.base.data.EFRowSet;
import com.efounder.builder.base.json.JSONUtil;
import com.efounder.eai.data.JParamObject;
import com.efounder.form.base.DataComponent;
import com.efounder.form.base.IComponent;
import com.efounder.frame.utils.EFAppAccountUtils;
import com.efounder.service.IService;
import com.efounder.utils.FileUtils;

/**
 * Created by Javor on 16/9/27.
 */

public class MDModelLoadService extends DataComponent implements IService, IComponent {
    private String fileName;

    @Override
    public Object executeService(JParamObject po, Object dao, Object co, Object userObject, Object ao) {
//        String json = FileUtils.readTextFile(EFAppAccountUtils.getAppAccountJsonPath() +"/" + fileName);
        String json = FileUtils.readTextFile(EFAppAccountUtils.getAppAccountMDMPath() +"/" + fileName);
        if (json == null || "".equals(json)) {
            Log.e("!!!!!","!!!!!mdm-json文件没读取到："+fileName);
            return null;
        }
        EFRowSet rowSet = JSONUtil.JSON2RowSet(json);
        return rowSet;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    private String id;

    @Override
    public String getID() {
        return id;
    }

    @Override
    public void setID(String id) {
        this.id = id;
    }

    @Override
    public void creationComplete() {

    }
}
